#include "Label.h"

#define LABEL_IMG_PATH "./trunk/res/img/fondomensaje.png"

Label::Label(std::string message, Widget* parent, int x, int y) :
	Widget(x, y, parent) {

	this->font = TTF_OpenFont("./trunk/res/font/Neuton.ttf", 18);

	if (font == NULL) {
		Logger::log("Label", "Label", "No se pudo inicializar la fuente");
	}

	this->textColor.r = 0;
	this->textColor.g = 0;
	this->textColor.b = 0;

	SDL_EnableUNICODE(SDL_ENABLE);

	this->message = message;

	char* c_message = new char[this->message.size() + 1];
	strcpy(c_message, this->message.c_str());

	this->messageSurface = TTF_RenderText_Solid(this->font, c_message,
			this->textColor);

	delete[] c_message;

	this->parcel = this->getPosition();
	this->parcel.height = this->messageSurface->h;
	this->parcel.width = this->messageSurface->w;

}

Label::~Label() {
	SDL_EnableUNICODE(SDL_DISABLE);
	TTF_CloseFont(this->font);
}

void Label::handleEvent(Event event) {
}

void Label::resolve() {

}
void Label::showOn(SDL_Surface* surface) {
	SDL_Rect rect;
	rect.x = parcel.posX;
	rect.y = parcel.posY;
	rect.w = parcel.width;
	rect.h = parcel.height;
	SDL_BlitSurface(this->messageSurface, NULL, surface, &rect);
}
